import React, { Suspense, lazy } from 'react';
// 导入字体图标
import "./assets/fonts/iconfont.css"
import './App.css';
// 导入虚拟化长列表的css样式
import 'react-virtualized/styles.css';
// 导入子组件
/* import Login from "views/Login"
import Layout from "views/Layout"
import City from 'views/city'
import Map from 'views/map'
import Detail from 'views/Detail';
import Rent from 'views/rent'
import AddRent from 'views/rent/addRent'
import AuthRoute from 'components/AuthRoute'
import Search from 'views/rent/search' */
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom'

//懒加载
const Login = lazy(() => import('views/Login'));
const Layout = lazy(() => import("views/Layout"));
const City = lazy(() => import('views/city'));
const Map = lazy(() => import('views/map'));
const Detail = lazy(() => import('views/Detail'));
const Rent = lazy(() => import('views/rent'));
const AddRent = lazy(() => import('views/rent/addRent'));
const AuthRoute = lazy(() => import('components/AuthRoute'));
const Search = lazy(() => import('views/rent/search'));
const Register = lazy(() => import('views/register'));
const EditData = lazy(() => import('views/editData'));


function App() {
  return (
    <div id="app">
      <HashRouter>
        <Suspense fallback={<div style={{ margin: "20px auto" }}>页面加载中...</div>}>
          <Switch>
            <Route path="/Login" component={Login} />
            <Route path="/Layout" component={Layout} />
            <Route path="/City" component={City} />
            <Route path="/Map" component={Map} />
            <Route path="/Detail:id" component={Detail} />
            <Route path="/register" component={Register} />
            <Route path="/editData" component={EditData} />
            <AuthRoute exact path="/rent" component={Rent} />
            <AuthRoute path="/rent/add" component={AddRent} />
            <AuthRoute path="/rent/search" component={Search} />
            {/* <Route path="/rent" exact render={props => {
            console.log(props,"rent里面")
            if(isAuth()) {
              return <Rent {...props} />
            } else {
              console.log(<Redirect to={{pathname: "/Login", state: {toPath:"/rent"}}} />,"重定向" )
              return <Redirect to={{pathname: "/Login", state: {toPath:"/rent"}}} />
            }
          }} />
          <Route path="/add/rent" exact render={props => {
            if(isAuth()) {
              return <AddRent {...props} />
            } else {
              return <Redirect to={{pathname: "/Login", state: {toPath: "/add/rent"}}} />
            }
          }} /> */}
            <Redirect exact from="/" to="Layout" />
          </Switch>
        </Suspense>
      </HashRouter>
    </div>
  );
}

export default App;
